package com.Ling.Thread.controller;

import com.Ling.Thread.sync.AsyncDemo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * File Name: AsyncTestController
 * Date: 2020-06-29 16:10
 * Author: liangling
 * Description 测试注解Async异步任务
 */
@RestController
@EnableAsync
public class AsyncTestController {

    @Autowired
    private AsyncDemo asyncDemo;

    @GetMapping("asyncTest")
    public void AsyncRun(){
        System.out.println("线程名称是："+Thread.currentThread().getName());

        asyncDemo.async();


    }




    //    @GetMapping("/asyncTest1")
//    public void AsyncRun2() throws ExecutionException, InterruptedException {
//        Future<String> result  = asyncDemo.futureAsync();
//        System.out.println("这是异步任务返回结果:"+result.get());
//    }
}
